package cn.cxy.stubdemo

import android.os.Bundle
import android.view.View
import androidx.appcompat.app.AppCompatActivity
import kotlinx.android.synthetic.main.activity_main.*
import kotlinx.android.synthetic.main.viewstub.*

class MainActivity : AppCompatActivity() {
    var stubView: View? = null
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
        showBtn.setOnClickListener {
            if (stubView == null) {
                stubView = viewStub.inflate()
            }
            textView.text = "我出现啦"
        }
    }
}